package com.example.administrator.xinyutg.activity;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;

import com.example.administrator.xinyutg.R;
import com.example.administrator.xinyutg.adapter.VpAdapter;

import java.util.ArrayList;
import java.util.List;

public class GuideActivity extends ActionBarActivity {

    private ViewPager vpGuide;
    private List<ImageView> listImg;
    private int[] images={R.mipmap.guidepage1,R.mipmap.guidepage2,R.mipmap.guidepage3,R.mipmap.guidepage4};
    private VpAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        initView();
        initData();
        adapter = new VpAdapter(listImg);
        vpGuide.setAdapter(adapter);

        listImg.get(listImg.size()-1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(GuideActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });

    }

    private void initData() {
        listImg = new ArrayList<ImageView>();
        for (int i = 0; i < images.length; i++) {
            ImageView iv=new ImageView(this);
            iv.setImageResource(images[i]);
            iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
            listImg.add(iv);
        }

    }

    private void initView() {
        vpGuide = (ViewPager) findViewById(R.id.vp_guide);
    }


}
